﻿using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace User.API.Data
{
    public class ApplicationDbContextSeed
    {
        public async System.Threading.Tasks.Task SeedAsync(ApplicationDbContext dbContext, IServiceProvider services)
        {
            var db = services.GetRequiredService<ApplicationDbContext>();

            if (!db.AppUser.Any())
            {
                var user = new AppUser()
                {
                    Name = "administrators",
                    Address = "Address",
                    Email = "519564415@qq.com",
                    Phone = "17551031463",
                    Tel = "84961814",
                    Title = ".NetCore开发工程师",
                    CardName = "张建",
                    Avatar = "http://www.qqzhi.com/uploadpic/2014-09-23/000247589.jpg",
                    City = "南京",
                    CityId = 1,
                    Province = "江苏",
                    ProvinceId = 1,
                    Company = "新华"
                };
                await db.AppUser.AddAsync(user);
                await db.SaveChangesAsync();
            }
        }
    }
}
